import java.util.ArrayList;
import java.util.Collections;
import java.util.Comparator;
import java.util.List;
import java.util.Map;
import java.util.Objects;
import java.util.Scanner;
import java.util.TreeMap;

public class Main4 {

    private static Scanner in;

    public static void main(String[] args) {
        in = new Scanner(System.in);
        ArrayList<String> List = new ArrayList<>();
        String st;
        st = in.next();
        while (st.compareTo("!!!!!") != 0) {
            List.add(st);
            st = in.next();
        }
        Map<String, Integer> map = new TreeMap<>();
        for (int i = 0; i < List.size(); i++) {
            if(map.containsKey(List.get(i)))
            {
            	 map.put(List.get(i), map.get(List.get(i))+1);
            }
            else map.put(List.get(i), 1);
        }
        List<Map.Entry<String,Integer>> list = new ArrayList<>(map.entrySet());
        System.out.println(map.size());
        
        Collections.sort(list, (Map.Entry<String, Integer> o1, Map.Entry<String, Integer> o2) -> {
            if(o1.getValue().compareTo(o2.getValue())==0)
                return o1.getKey().compareTo(o2.getKey());
            else return o2.getValue()-o1.getValue();
        });
        if (map.size() > 10) {
            for (int i = 0; i < 10; i++) {
                System.out.println(list.get(i).getKey()+"="+list.get(i).getValue());
            }
        } else {
            for (int i = 0; i < map.size(); i++) {
                System.out.println(list.get(i).getKey()+"="+list.get(i).getValue());
            }
        }

    }
}
